package org.wj.config.temperature;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * 分组比较器。 控制哪些键要分组到一个Reducer.reduce()函数调用
 */
public class DateTemperatureGroupingComparator extends WritableComparator {

    public DateTemperatureGroupingComparator() {
        super(DateTemperaturePair.class, true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        DateTemperaturePair p1 = (DateTemperaturePair) a;
        DateTemperaturePair p2 = (DateTemperaturePair) b;
        return p1.getYearMonth().compareTo(p2.getYearMonth());
    }
}
